import { addNameSpace } from './util'

const NAME_SPACE = 'REGISTER'

const addPrefix = addNameSpace(NAME_SPACE)

// 输入手机号
export const SET_PHONE_NUM = addPrefix('SET_PHONE_NUM')

// 输入验证码
export const SET_VALIDATE_CODE = addPrefix('SET_VALIDATE_CODE')

// 输入公司
export const SET_COMPANY = addPrefix('SET_COMPANY')

// 输入名字
export const SET_NAME = addPrefix('SET_NAME')

// 获取验证码
export const GET_VALIDATE_CODE = addPrefix('GET_VALIDATE_CODE')

// 设置验证码倒计时
export const SET_VALIDATE_CODE_COUNT_DOWN = addPrefix('SET_VALIDATE_CODE_COUNT_DOWN')

// 设置验证码按钮可用
export const SET_VALIDATE_BUTTON_ENABLE = addPrefix('SET_VALIDATE_BUTTON_ENABLE')

// 注册
export const REGISTER = addPrefix('REGISTER')

// 注册成功
export const REGISTER_SUCCESS = addPrefix('REGISTER_SUCCESS')

// 注册失败
export const REGISTER_FAIL = addPrefix('REGISTER_FAIL')

export const setPhoneNum = (phoneNum) => ({ type: SET_PHONE_NUM, phoneNum })

export const setValidateCode = (validateCode) => ({ type: SET_VALIDATE_CODE, validateCode })

export const setCompany = (company) => ({ type: SET_COMPANY, company })

export const setName = (name) => ({ type: SET_NAME, name })

export const getValidateCode = () => ({ type: GET_VALIDATE_CODE })

export const setValidateCodeCountDown = (validateCodeCountDown) => ({ type: SET_VALIDATE_CODE_COUNT_DOWN, validateCodeCountDown })

export const setValidateButtonEnable = () => ({ type: SET_VALIDATE_BUTTON_ENABLE })

export const register = () => ({ type: REGISTER })

export const registerSuccess = () => ({ type: REGISTER_SUCCESS })

export const registerFail = () => ({ type: REGISTER_FAIL })

export default {
  setPhoneNum,
  setValidateCode,
  setCompany,
  setName,
  getValidateCode,
  setValidateCodeCountDown,
  setValidateButtonEnable,
  register,
  registerSuccess,
  registerFail,
}